<!--
 * @Author: ChenCaoYang
 * @Date: 2021-05-29 21:10:08
 * @LastEditors: ChenCaoYang
 * @LastEditTime: 2021-06-06 12:28:41
-->
<template>
  <div class="container">
    <h3>发布评论</h3>
    <el-divider></el-divider>
    <!-- 编辑内容 -->
    <div class="content">
      <h4>评论商品</h4>
      <div class="product_info">
        <div class="img_box">
          <img :src="this.$route.query.titlePicUrl" alt />
        </div>
        <div class="product_dec">
          <strong>{{ this.$route.query.productName }}</strong>
          <p>{{ this.$route.query.productSpecs }}</p>
        </div>
      </div>
      <el-divider></el-divider>
      <h4>评论描述</h4>
      <div class="submitText">
        <el-input
          type="textarea"
          :rows="5"
          placeholder="请输入内容"
          v-model="textarea"
        ></el-input>
        <el-button type="warning" round @click="evaluatePro()" size="small"
          >发表回复</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { get_data } from '../../utils/utils'
export default {
  name: 'refundDetails', //退款详情
  data() {
    return {
      textarea: '',
    }
  },
  mounted() {},
  methods: {
    evaluatePro() {
      console.log(this.$route.query.orderData)
      this.$http
        .fetch(this.$apiPath.evaluatePro, {
          method: 'POST',
          data: {
            customerId: JSON.parse(get_data('userInfo')).id,
            productId: this.$route.query.productId,
            reviewsContent: this.textarea,
          },
        })
        .then((res) => {
          if (res.code == 200) {
            this.$message('发布成功')
            this.textarea = ''
            this.$router.go(-1)
          } else {
            this.$message(res.msg)
          }
        })
    },
  },
}
</script>

<style scoped lang="less">
.container {
  width: 1200px;
  padding-top: 40px;
  margin: 0 auto;
  .content {
    padding: 0 22px;
    .product_info {
      display: flex;
      align-items: center;
      margin-top: 24px;
      .img_box {
        width: 100px;
        height: 100px;
        margin-right: 24px;
        img {
          width: 100%;
          height: 100%;
          border-radius: 5px;
        }
      }
      .product_dec {
        font-size: 14px;
        font-weight: 400;
        color: #666666;
        line-height: 30px;
      }
    }
    .submitText {
      width: 50%;
      .el-textarea {
        margin-top: 24px;
      }
      button {
        float: right;
        margin-top: 20px;
      }
    }
  }
}
</style>
